package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.itheima.bean.Setmeal;
import com.itheima.dao.SetMealDao;
import com.itheima.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author: LiuBanXian
 * @Date: 2022/9/4  15:39
 * @description:
 */
@Service
@Transactional
public class SetmealServiceImpl implements SetmealService {
    @Autowired
    private SetMealDao setMealDao;

    @Override
    public List<Setmeal> findByCategoryId(long id) {
        LambdaQueryWrapper<Setmeal> lqw = new LambdaQueryWrapper<>();
        lqw.eq(Setmeal::getCategoryId, id);
        return setMealDao.selectList(lqw);
    }

    @Override
    public List<Setmeal> findByCategoryId(Long categoryId, Integer status) {
        LambdaUpdateWrapper<Setmeal> lqw = new LambdaUpdateWrapper<>();

        lqw.eq(Setmeal::getCategoryId,categoryId);
        lqw.eq(Setmeal::getStatus,status);
        return setMealDao.selectList(lqw);
    }
}
